package modules.citysection.bottom
{
import com.greensock.TweenLite;

import core.module.ModuleManager;

import flash.display.DisplayObject;
import flash.display.MovieClip;

import framework.proxy.ComponentProxy;
import framework.view.components.button.ButtonProxy;

import view.component.button.SwitchButtonProxy;
import view.interfaces.IBottomUI;

/**
 * CitySectionBottomUIProxy
 * @author jliang
 * 
 */
public class CitySectionBottomUIProxy extends ComponentProxy implements IBottomUI
{
    //==========================================================================
    //  Class constants
    //==========================================================================
    private static const SHOW_OFFSET:Number = 155;
    
    private static const HIDE_MOVE_OFFSET:Number = 92;
	//==========================================================================
	//  Constructor
	//==========================================================================
	public function CitySectionBottomUIProxy()
	{
		super();
	}
    //==========================================================================
    //  Properties
    //==========================================================================
    public function get displayObject():DisplayObject
    {
        return this.skinContent;
    }
    
    public function get switchBtn():SwitchButtonProxy
    {
        return proxys["switchBtn"];
    }
    
    public function get friendUI():FriendUIProxy
    {
        return proxys["friendUI"];
    }
	//==========================================================================
	//  Overridden methods: ComponentProxy
	//==========================================================================
    override protected function get proxyMapping():Array
    {
        return [ 
            { skin:"switchBtn", classRef: SwitchButtonProxy, id:"switchBtn" },
            { skin:"shopBtn", classRef: ButtonProxy, id:"shopBtn", onClick: onClickShopMenuHandler },
            { skin:"heroBtn", classRef: ButtonProxy, id:"heroBtn", onClick: onClickHeroMenuHandler },
            { skin:"skillBtn", classRef: ButtonProxy, id:"skillBtn", onClick: onClickSkillMenuHandler },
            { skin:"inventoryBtn", classRef: ButtonProxy, id:"inventoryBtn", onClick: onClickInventoryMenuHandler },
            { skin:"giftBoxBtn", classRef: ButtonProxy, id:"giftBoxBtn", onClick: onClickGiftBoxMenuHandler },
            { skin:"toolBtn", classRef: ButtonProxy, id:"toolBtn", onClick: onClickToolMenuHandler },
            { skin:"worldBtn", classRef: ButtonProxy, id:"worldBtn", onClick: onClickToWorldHandler },
            { skin:"arenaBtn", classRef: ButtonProxy, id:"arenaBtn", onClick: onClickToArenaHandler },
            { skin:"caveBtn", classRef: ButtonProxy, id:"caveBtn", onClick: onClickToCaveHandler },
            { skin:"friendUI", classRef: FriendUIProxy, id:"friendUI" }
        ].concat(super.proxyMapping);
    }
    
    override public function parse(target:MovieClip):void
    {
        super.parse(target);
        
        switchBtn.switchHandler = switchHandler;
    }
	//==========================================================================
	//  Event handlers
	//==========================================================================	
	private function onClickShopMenuHandler():void
	{
		Game.instance.shopUI.showShop();
	}
    
    private function onClickHeroMenuHandler():void
    {
        Game.instance.heroUI.showHero();
    }
    
    private function onClickSkillMenuHandler():void
    {
        Game.instance.skillUI.showHeroSkill();
    }
	
	private function onClickInventoryMenuHandler():void
	{
		Game.instance.inventoryUI.showInventory();
	}
    
    private function onClickGiftBoxMenuHandler():void
	{
		Game.instance.changeSection("battle_module");
    }
    
    private function onClickToolMenuHandler():void
    {
        
    }
    
    private function onClickToWorldHandler():void
    {	
		
    }
    
    private function onClickToArenaHandler():void
    {
        
    }
    
    private function onClickToCaveHandler():void
    {
        
    }
    
    private function switchHandler(mode:String):void
    {
        skin.mouseChildren = false;
        
        TweenLite.to(skin, 0.5, { y: skin.y + (mode == "hide" ? HIDE_MOVE_OFFSET : -HIDE_MOVE_OFFSET), onComplete:moveComplete  });
    }
    
    private function moveComplete():void
    {
        skin.mouseChildren = true;
    }
}
}



